﻿@model IEnumerable<ManageReportVer1.Models.User>

@{
    ViewBag.Title = "ViewUsers";
    Layout = "~/Views/Shared/_LayoutSecurityGuard.cshtml";
}
<div id="breadcrumb">
    @Html.ActionLink("Quản lý người dùng", "Index", "Account") >
    Danh sách tài khoản
</div>
<h2>Danh sách người dùng</h2>
<p class="p1">
    @Html.ActionLink("Tạo tài khoản mới", "Register")
</p>
@*@using (Html.BeginForm())
{
    <select id="filterby" name="filterby">
        <option value="all" @if(Model.FilterBy == "all"){ <text>selected="selected"</text>}>View All</option>
        <option value="username" @if (Model.FilterBy == "username"){ <text>selected="selected"</text>}>UserName</option>
        <option value="email" @if (Model.FilterBy == "email"){ <text>selected="selected"</text>}>Email</option>
    </select>
    <text>&nbsp;Starts with:</text> @Html.TextBox("searchterm", Model.SearchTerm) 

    <input type="submit" id="filter-button" value="Search" />
}
<br />*@
<p>
   @* @Html.ActionLink("Tạo tài khoản mới", "Register")*@
</p>
<div class="table_wrapper">
    <div class="table_wrapper_scroll">
<table  id="tableDiv" width="100%" cellspacing="0" cellpadding="0">
    <tbody>
    <tr>
        <th> </th>
        <th>
            @Html.DisplayNameFor(model => model.UserName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Password)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Email)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.PasswordQuestion)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.PasswordAnswer)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.IsApproved)
        </th>
@*        <th>
            @Html.DisplayNameFor(model => model.IsLockedOut)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.CreateDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.LastLoginDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.LastPasswordChangedDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.LastLockoutDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FailedPasswordAttemptCount)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FailedPasswordAttemptWindowStart)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FailedPasswordAnswerAttemptCount)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FailedPasswordAnswerAttemptWindowsStart)
        </th>*@
        <th>
            @Html.DisplayNameFor(model => model.Comment)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.DepartmentId)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FirstName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.LastName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Honorary)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Address)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Telephone)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.NickName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.DateOfBirth)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Gender)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.MaritalStatus)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Photo)
        </th>
         <th>
            @Html.DisplayNameFor(model => model.RoleId)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            <input type="radio" name="userName" value="@item.UserName" class="userRadio" />
        </td>
        <td>
            @*@Html.DisplayFor(modelItem => item.UserName)*@
          @*  @Html.ActionLink(item.UserName, "UpdateUser", "Account", new { id=item.UserId }, null)*@
            @Html.ActionLink(item.UserName, "UpdateUser", new { id=item.UserId })
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Password)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Email)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PasswordQuestion)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PasswordAnswer)
        </td>
        <td>
            @*@Html.DisplayFor(modelItem => item.IsApproved)*@
            @if (item.IsApproved==true)
                 {
                    <text><span class="system positive">Approved</span></text>
                 }
              else
                  {
                    <text><span class="system negative">Not Approved</span></text>   
                  }
        </td>
     @*   <td>
            @Html.DisplayFor(modelItem => item.IsLockedOut)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CreateDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastLoginDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastPasswordChangedDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastLockoutDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FailedPasswordAttemptCount)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FailedPasswordAttemptWindowStart)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FailedPasswordAnswerAttemptCount)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FailedPasswordAnswerAttemptWindowsStart)
        </td>*@
        <td>
            @Html.DisplayFor(modelItem => item.Comment)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DepartmentId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FirstName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Honorary)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Address)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Telephone)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.NickName)
        </td>
        <td>
            @Html.LabelFor(modelItem => item.DateOfBirth.Date, String.Format("{0:d}", item.DateOfBirth.Date))
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Gender)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.MaritalStatus)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Photo)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.RoleId)
        </td>
        <td id="tdchucnang">
            @Html.ActionLink("Cập nhật", "UpdateUser", new { id=item.UserId })|
            @Html.ActionLink("Chi tiết", "Details", new {  id=item.UserId })|
            @Html.ActionLink("Xóa", "DeleteUser", new { id=item.UserId }, new { onclick = " return DeleteConfirm()" })
        </td>
    </tr>
}
        </tbody>
    </table>
</div>
    </div>
<div class="backToView">
    @Html.ActionLink("Quay lại danh sách người dùng", "ViewUsers")
</div>
<script type="text/javascript">
    function DeleteConfirm() {
        if (confirm("Bạn có chắc chắn muốn xóa?"))
            return true;
        else
            return false;
    }
</script>